eststo clear
clear matrix
use "DB governor estimations.dta", clear


label var dem_mean "Democrat"
label var dummy_energy_nat "Polluting Sector"
label var democrat_energy_nat "Democrat*Polluting Sector"
label var energy_nat_oil "Polluting Sector*Oil"
label var democrat_energy_nat_oil "Democrat*Polluting Sector*Oil"
label var energy_nat_gsp "Polluting Sector*\% GSP poll. sectors"
label var democrat_energy_nat_gsp "Democrat*Polluting Sector*\% GSP poll. sectors"
label var general_election_mean "General Election"

***********************************************************************************************
*                  TABLE 2: Determinants of Political Contributions, 2000-2014                *                                     *
***********************************************************************************************

* OLS Regressions
*================
reghdfe ln_total_cand_ind dem_mean dummy_energy_nat democrat_energy_nat general_election_mean , absorb(election_jurisdiction_fb year) cluster(idy)
est store A
estadd local fixed_state "yes" 
estadd local fixed_industry "no" 
estadd local fixed_candidate "no" 

reghdfe ln_total_cand_ind dem_mean  democrat_energy_nat  general_election_mean dy* , absorb(industry_panel election_jurisdiction_fb) cluster(idy)
est store C
reghdfe ln_total_cand_ind dem_mean dummy_energy_nat democrat_energy_nat energy_nat_oil  democrat_energy_nat_oil general_election_mean , absorb(election_jurisdiction_fb year) cluster(idy)
est store B
reghdfe ln_total_cand_ind dem_mean  democrat_energy_nat energy_nat_oil  democrat_energy_nat_oil general_election_mean dy* , absorb(industry_panel election_jurisdiction_fb) cluster(idy)
est store C
reghdfe ln_total_cand_ind dummy_energy_nat democrat_energy_nat energy_nat_oil  democrat_energy_nat_oil , absorb(id year) cluster(idy)
est store D

* Using GSP instead of oil
*=========================

reghdfe ln_total_cand_ind dem_mean dummy_energy_nat democrat_energy_nat energy_nat_gsp  democrat_energy_nat_gsp general_election_mean , absorb(election_jurisdiction_fb year) cluster(idy)
est store E
reghdfe ln_total_cand_ind dem_mean  democrat_energy_nat energy_nat_gsp  democrat_energy_nat_gsp general_election_mean dy* , absorb(industry_panel election_jurisdiction_fb) cluster(idy)
est store F
reghdfe ln_total_cand_ind dummy_energy_nat democrat_energy_nat energy_nat_gsp  democrat_energy_nat_gsp , absorb(id year) cluster(idy)
est store G
esttab A B C D E F G using tab2.tex, r2 star(* .1 ** .05 *** .01) b(3) replace drop(dy*) label


***********************************************************************************************
*           TABLE 3: Governor's Political Ideology and Environmental Expenditures             *
***********************************************************************************************
use "DB final estimation.dta", clear

label var ln_envi_exp_real_pc "ln(Env. Exp.)"
label var democrat "Democrat"
label var aged "\% Pop.>65 yrs."
label var kids "\% Pop.<17 yrs."
label var ln_population "(ln) Population"
label var ln_income_pc_real "(ln) Personal Income"

global poly_4 "MV MV_2 MV_3 MV_4 dem_MV dem_MV2 dem_MV3 dem_MV4"
global poly_3 "MV MV_2 MV_3 dem_MV dem_MV2 dem_MV3"
global poly_2 "MV MV_2 dem_MV dem_MV2"
global poly_1 "MV dem_MV"


reghdfe ln_envi_exp_real_pc democrat $poly_1 aged kids ln_population ln_income_pc_real  , absorb(id year) vce(cluster id)
est store H
reghdfe ln_envi_exp_real_pc democrat $poly_2 aged kids ln_population ln_income_pc_real  , absorb(id year) vce(cluster id)
est store I
reghdfe ln_envi_exp_real_pc democrat $poly_3 aged kids ln_population ln_income_pc_real  , absorb(id year) vce(cluster id)
est store L
reghdfe ln_envi_exp_real_pc democrat $poly_4 aged kids ln_population ln_income_pc_real  , absorb(id year) vce(cluster id)
est store M

esttab H I L M using tab3.tex, star (* 0.10 ** 0.05 *** 0.01) replace label drop(MV_* dem_MV*)

***********************************************************************************************
*                TABLE 4: RDD, Heterogenous effects using interaction terms                   *
***********************************************************************************************

* Splitting by Oil Reserves/State's Area
label var dem_high_oil_area "Democrat*Oil/Area $>$ Median"
label var dem_low_oil_area "Democrat*Oil/Area $<=$ Median"

reghdfe ln_envi_exp_real_pc  dem_high_oil_area dem_low_oil_area  $poly_1 aged kids ln_population ln_income_pc_real, absorb(id year) vce(cluster id)
est store N

* Splitting by GSP polluting industries

label var dem_high_GSP "Democrat*\% GSP poll. ind $>$ Median"
label var dem_low_GSP "Democrat*\% GSP poll. ind $<=$ Median"

reghdfe ln_envi_exp_real_pc  dem_high_GSP dem_low_GSP  $poly_1 aged kids ln_population ln_income_pc_real, absorb(id year) vce(cluster id)
est store O

* Considering South Issue
label var democrat_south "Democrat*South States"
label var democrat_no_south "Democrat*Non-South States"

reghdfe ln_envi_exp_real_pc democrat_south democrat_no_south $poly_1 aged kids ln_population ln_income_pc_real, absorb(id year) vce(cluster id)
est store P

* Splitting by Percentage of Green Voters
label var dem_high_green "Democrat*Green Voters $>$ Median" 
label var dem_low_green "Democrat*Green Voters $<=$ Median" 

reghdfe ln_envi_exp_real_pc  dem_high_green dem_low_green  $poly_1 aged kids ln_population ln_income_pc_real, absorb(id year) vce(cluster id)
est store Q

* Splitting by Term limit
label var dem_term "Democrat*Non Term Limited" 
label var dem_no_term "Democrat*Term Limited" 

reghdfe ln_envi_exp_real_pc dem_term dem_no_term $poly_1 aged kids ln_population ln_income_pc_real, absorb(id year) vce(cluster id)
est store R

* Excluding candidates defeated at reelection
reghdfe ln_envi_exp_real_pc dem_term dem_no_term $poly_1 aged kids ln_population ln_income_pc_real if defeated_reelection !=1 , absorb(id year) vce(cluster id)
est store S

esttab N O P Q R S using tab4.tex, star (* 0.10 ** 0.05 *** 0.01) replace label drop(MV dem_MV)

************************************************************************************************
*            TABLE 5: RDD with Heterogeneous Effects, Democratic Margin of Victory             *
************************************************************************************************

label var dem_oil "Democrat*Oil"
label var dem_green "Democrat*Green Voters"
label var dem_green_oil "Democrat*Green Voters*Oil"
label var dem_term_limit "Democrat*Term Limit"
label var dem_oil_term_limit "Democrat*Oil*Term Limit"
label var dem_green_term_limit "Democrat*Term Limit*Oil"

* Oil reserves interaction
reghdfe ln_envi_exp_real_pc democrat dem_oil $poly_1 aged kids ln_population ln_income_pc_real, absorb(id year) vce(cluster id)
est store A5_1
* Oil reserves interaction - dropping South States 
reghdfe ln_envi_exp_real_pc democrat dem_oil $poly_1 aged kids ln_population ln_income_pc_real if dummy_south==0, absorb(id year) vce(cluster id)
est store A5_2
* Controlling for GSP
reghdfe ln_envi_exp_real_pc democrat dem_GSP_polluting $poly_1 aged kids ln_population ln_income_pc_real , absorb(id year) vce(cluster id)
est store A5_3
* Also excluding southern state dummy 
reghdfe ln_envi_exp_real_pc democrat dem_GSP_polluting $poly_1 aged kids ln_population ln_income_pc_real if dummy_south==0, absorb(id year) vce(cluster id)
est store A5_4
* Controlling for GSP and Green Voters
reghdfe ln_envi_exp_real_pc democrat dem_GSP_polluting dem_green $poly_1 aged kids ln_population ln_income_pc_real , absorb(id year) vce(cluster id)
est store A5_5
* Controlling for GSP and Term Limit
reghdfe ln_envi_exp_real_pc democrat dem_GSP_polluting dem_term_limit $poly_1 aged kids ln_population ln_income_pc_real , absorb(id year) vce(cluster id)
est store A5_6


esttab A5_1 A5_2 A5_3 A5_4 A5_5 A5_6 using tab5.tex, star (* 0.10 ** 0.05 *** 0.01) replace label drop(aged kids ln_population ln_income_pc_real MV dem_MV)


*-----------------------------------------------------------
*                         Appendix                         *
*-----------------------------------------------------------



***********************************************************************************************
*       TABLE A.1: Determinants of Political Contributions, 2000-2014 PPML regressions        *                                     *
***********************************************************************************************
use "DB governor estimations.dta", clear


* PPML Regressions
*================?
poi2hdfe total_cand_ind dem_mean dummy_energy_nat democrat_energy_nat  general_election_mean , id1(election_jurisdiction_fb) id2(year) cluster(idy)
est store A11
estadd local fixed_state "yes" 
estadd local fixed_industry "no" 
estadd local fixed_candidate "no" 
poi2hdfe total_cand_ind dem_mean democrat_energy_nat  general_election_mean dy* , id1(industry_panel) id2(election_jurisdiction_fb) cluster(idy)
est store A12
poi2hdfe total_cand_ind dem_mean dummy_energy_nat democrat_energy_nat energy_nat_oil  democrat_energy_nat_oil general_election_mean , id1(election_jurisdiction_fb) id2(year) cluster(idy)
est store A13
poi2hdfe total_cand_ind dem_mean democrat_energy_nat energy_nat_oil  democrat_energy_nat_oil general_election_mean dy* , id1(industry_panel) id2(election_jurisdiction_fb) cluster(idy)
est store A14
poi2hdfe total_cand_ind dummy_energy_nat democrat_energy_nat energy_nat_oil  democrat_energy_nat_oil , id1(id) id2(year) cluster(idy)
est store A15

* Usins GSP instead of oil
*=========================

poi2hdfe total_cand_ind dem_mean dummy_energy_nat democrat_energy_nat energy_nat_gsp  democrat_energy_nat_gsp general_election_mean , id1(election_jurisdiction_fb) id2(year) cluster(idy)
est store A16
poi2hdfe total_cand_ind dem_mean democrat_energy_nat energy_nat_gsp  democrat_energy_nat_gsp general_election_mean dy* , id1(industry_panel) id2(election_jurisdiction_fb) cluster(idy)
est store A17
poi2hdfe total_cand_ind dummy_energy_nat democrat_energy_nat energy_nat_gsp  democrat_energy_nat_gsp , id1(id) id2(year) cluster(idy)
est store A18

esttab A11 A12 A13 A14 A15 A16 A17 A18 using tabA1.tex, r2 star(* .1 ** .05 *** .01) replace drop(dy*) b(3) label

****************************************************************************************************
********* Table A.2: RDD with Dependent Variable from Previous and Subsequent Terms ****************
****************************************************************************************************
use "DB final estimation.dta", clear

label var ln_envi_exp_real_pc "ln(Env. Exp.)"
label var democrat "Democrat"
label var aged "\% Pop.>65 yrs."
label var kids "\% Pop.<17 yrs."
label var ln_population "(ln) Population"
label var ln_income_pc_real "(ln) Personal Income"

* ENVIRONMENTAL EXPENDITURES from previous term (t-1)


*** Third order polynomial: t-1
reghdfe ln_envi_exp_lagged democrat $poly_1 aged kids ln_population ln_income_pc_real, absorb(id year) vce(cluster id)
est store A21
*** Fourth order polynomial: t-1
reghdfe ln_envi_exp_lagged democrat $poly_2 aged kids ln_population ln_income_pc_real, absorb(id year) vce(cluster id)
est store A22

* ENVIRONMENTAL EXPENDITURES from subsequent term (t+1)

***Third order polynomial: t+1
reghdfe ln_envi_exp_post democrat $poly_1 aged kids ln_population ln_income_pc_real, absorb(id year) vce(cluster id)
est store A23
***Fourth order polynomial: t+1
reghdfe ln_envi_exp_post democrat $poly_2 aged kids ln_population ln_income_pc_real, absorb(id year) vce(cluster id)
est store A24

esttab A21 A22 A23 A24 using  tabA2.tex, star (* 0.10 ** 0.05 *** 0.01) b(3) replace label drop(MV MV_* dem_MV*)

****************************************************************************************************
******************** Table A.3: Placebo Test: RDD with Baseline Covariates ***************************
****************************************************************************************************

reghdfe aged democrat $poly_1 kids  ln_income_pc_real ln_population , absorb(id year) vce(cluster id)
est store A31
reghdfe kids democrat $poly_1 aged ln_income_pc_real ln_population, absorb(id year) vce(cluster id)
est store A32
reghdfe ln_population democrat $poly_1 aged kids  ln_income_pc_real   , absorb(id year) vce(cluster id)
est store A33
reghdfe ln_income_pc_real democrat aged kids ln_population $poly_1   , absorb(id year) vce(cluster id)
est store A34

esttab A31 A32 A33 A34 using tabA3.tex, star (* 0.10 ** 0.05 *** 0.01) b(3) replace label drop(MV dem_MV)

****************************************************************************************************
********* Table A.4: Results 1970-2014 using Oil reserves as proxy for lobby activity **************
****************************************************************************************************

use "DB 1970-2014.dta", clear

reghdfe ln_envi_exp_real_pc democrat dem_oil_UPD $poly_1  , absorb(id_UPD year) vce(cluster id_UPD)
est store A41
reghdfe ln_envi_exp_real_pc democrat dem_oil_UPD $poly_2  , absorb(id_UPD year) vce(cluster id_UPD)
est store A42
reghdfe ln_envi_exp_real_pc democrat dem_oil_UPD $poly_3  , absorb(id_UPD year) vce(cluster id_UPD)
est store A43
reghdfe ln_envi_exp_real_pc democrat dem_oil_UPD $poly_4  , absorb(id_UPD year) vce(cluster id_UPD)
est store A44
esttab A41 A42 A43 A44 using tabA4_1.csv, star (* 0.10 ** 0.05 *** 0.01) replace label drop(MV MV_* dem_MV*) b(3)

*** Effect over time
* Before 1993
reghdfe ln_envi_exp_real_pc democrat dem_oil_UPD $poly_1 if year<1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A45
reghdfe ln_envi_exp_real_pc democrat dem_oil_UPD $poly_2 if year<1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A46
reghdfe ln_envi_exp_real_pc democrat dem_oil_UPD $poly_3 if year<1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A47
reghdfe ln_envi_exp_real_pc democrat dem_oil_UPD $poly_4 if year<1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A48
esttab A45 A46 A47 A48 using tabA4_2.csv, star (* 0.10 ** 0.05 *** 0.01) replace label drop(MV MV_* dem_MV*) b(3)

* After 1993
reghdfe ln_envi_exp_real_pc democrat dem_oil_UPD $poly_1 if year >=1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A49
reghdfe ln_envi_exp_real_pc democrat dem_oil_UPD $poly_2 if year >=1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A50
reghdfe ln_envi_exp_real_pc democrat dem_oil_UPD $poly_3 if year >=1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A51
reghdfe ln_envi_exp_real_pc democrat dem_oil_UPD $poly_4 if year >=1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A52


esttab A49 A50 A51 A52 using tabA4_3.csv, star (* 0.10 ** 0.05 *** 0.01) replace label drop(MV MV_* dem_MV*) b(3)


**********************************************************************************************************
* Table A.5: Results 1970-2014 using using share of GSP polluting industries as proxy for lobby activity *
**********************************************************************************************************
clear matrix

reghdfe ln_envi_exp_real_pc democrat dem_gsp_UPD $poly_1  , absorb(id_UPD year) vce(cluster id_UPD)
est store A51_1
reghdfe ln_envi_exp_real_pc democrat dem_gsp_UPD $poly_2  , absorb(id_UPD year) vce(cluster id_UPD)
est store A52_1
reghdfe ln_envi_exp_real_pc democrat dem_gsp_UPD $poly_3  , absorb(id_UPD year) vce(cluster id_UPD)
est store A53
reghdfe ln_envi_exp_real_pc democrat dem_gsp_UPD $poly_4  , absorb(id_UPD year) vce(cluster id_UPD)
est store A54
esttab A51_1 A52_1 A53 A53 using tabA5_1.csv, star (* 0.10 ** 0.05 *** 0.01) replace label drop(MV MV_* dem_MV*) b(3)

*** Effect over time
* Before 1993
reghdfe ln_envi_exp_real_pc democrat dem_gsp_UPD $poly_1 if year<1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A55
reghdfe ln_envi_exp_real_pc democrat dem_gsp_UPD $poly_2 if year<1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A56
reghdfe ln_envi_exp_real_pc democrat dem_gsp_UPD $poly_3 if year<1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A57
reghdfe ln_envi_exp_real_pc democrat dem_gsp_UPD $poly_4 if year<1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A58
esttab A55 A56 A57 A58 using tabA5_2.csv, star (* 0.10 ** 0.05 *** 0.01) replace label drop(MV MV_* dem_MV*) b(3)

* After 1993
reghdfe ln_envi_exp_real_pc democrat dem_gsp_UPD $poly_1 if year >=1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A59
reghdfe ln_envi_exp_real_pc democrat dem_gsp_UPD $poly_2 if year >=1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A60
reghdfe ln_envi_exp_real_pc democrat dem_gsp_UPD $poly_3 if year >=1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A61
reghdfe ln_envi_exp_real_pc democrat dem_gsp_UPD $poly_4 if year >=1993, absorb(id_UPD year) vce(cluster id_UPD)
est store A62


esttab A59 A60 A61 A62 using tabA5_3.csv, star (* 0.10 ** 0.05 *** 0.01) replace label drop(MV MV_* dem_MV*) b(3)
